<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="../static/utils/http.js"></script>

    <title>测试企业微信登录成功页面</title>

</head>
<body>
    测试企业微信登录成功页面
    <div id = "pr"></div>
    请完善用户信息
    <form id="info" style="display: none">
        <input type="hidden" id="userid" name="userid" >
        账号:<input type="text" name="username" id="username">
        密码:<input type="password" name="password" id="password">

    </form>

    <button value="提交" >提交</button>

    <script>
        $(document).ready(function () {

            var request =http.getRequest();
            var code = request['code'];
            console.log(code);

            http.post("/wx/getUserInfo",{"code":code}).then(function (res) {
                if (res.code == 1){
                    $("#pr").append("<img src='"+res.data.user.pic+"'/>");
                    $("#pr").append("<img src='../img/q'/>");

                    if (res.data.user.username == null && res.data.user.password==null){
                        $("#info").css('display','block');

                        $("#userid").attr("value",res.data.user.id);
                    }else if(res.data.wxUserId != undefined){
                        $("#pr").append("<p>在业务系统中检测到您已经有账号"+res.data.user.username+",是否要进行账号合并?</p>");
                        $("#pr").append("<input type='button'>在业务系统中检测到您已经有账号"+res.data.user.username+",是否要进行账号合并?</input>");


                    }
                }


            });

            $("button").click(function(){
                var username = $("#username").val();
                var password = $("#password").val();
                var userid = $("#userid").val();

                http.post("/wx/consummateInfo",{"username":username,"password":password,id:userid}).then(function (res) {
                    if (res.code == 1){
                        alert(res.msg)
                        return null;
                    }

                });

        });
        });
    </script>

</body>



</html>